namespace Isolation.TeamFoundationServer
{
	#region #using Directives

	using System;

	using Microsoft.TeamFoundation.Build.Client;

	#endregion

	internal class TfsBuildDetail : ITfsBuildDetail
	{
		private readonly IBuildDetail buildDetail;

		internal TfsBuildDetail(IBuildDetail buildDetail)
		{
			this.buildDetail = buildDetail;
		}

		#region Implementation of ITfsBuildDetail

		public TfsBuildStatus Status
		{
			get
			{
				try
				{
					switch (this.buildDetail.Status)
					{
						case BuildStatus.InProgress:
							return TfsBuildStatus.InProgress;
						case BuildStatus.Succeeded:
							return TfsBuildStatus.Succeeded;
						case BuildStatus.PartiallySucceeded:
							return TfsBuildStatus.PartiallySucceeded;
						case BuildStatus.Failed:
							return TfsBuildStatus.Failed;
						case BuildStatus.Stopped:
							return TfsBuildStatus.Stopped;
						case BuildStatus.NotStarted:
							return TfsBuildStatus.NotStarted;
						default:
							throw new InvalidOperationException();
					}
				}
				catch (Microsoft.TeamFoundation.TeamFoundationServerException tfse)
				{
					throw new TeamFoundationServerException(tfse);
				}
			}
		}

		public string BuildDefinitionName
		{
			get
			{
				try
				{
					return this.buildDetail.BuildDefinition.Name;
				}
				catch (Microsoft.TeamFoundation.TeamFoundationServerException tfse)
				{
					throw new TeamFoundationServerException(tfse);
				}
			}
		}

		public string BuildNumber
		{
			get
			{
				try
				{
					return this.buildDetail.BuildNumber;
				}
				catch (Microsoft.TeamFoundation.TeamFoundationServerException tfse)
				{
					throw new TeamFoundationServerException(tfse);
				}
			}
		}

		public DateTime FinishTime
		{
			get
			{
				try
				{
					return this.buildDetail.FinishTime;
				}
				catch (Microsoft.TeamFoundation.TeamFoundationServerException tfse)
				{
					throw new TeamFoundationServerException(tfse);
				}
			}
		}

		public DateTime LastChangedOn
		{
			get
			{
				try
				{
					return this.buildDetail.LastChangedOn;
				}
				catch (Microsoft.TeamFoundation.TeamFoundationServerException tfse)
				{
					throw new TeamFoundationServerException(tfse);
				}
			}
		}

		public string RequestedFor
		{
			get
			{
				try
				{
					return this.buildDetail.RequestedFor;
				}
				catch (Microsoft.TeamFoundation.TeamFoundationServerException tfse)
				{
					throw new TeamFoundationServerException(tfse);
				}
			}
		}

		#endregion
	}
}